home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / font / CompositeFont.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  5.1 KB  |  302 lines

  1. package sun.font;
  2.  
  3. import java.security.AccessController;
  4. import java.util.Locale;
  5. import sun.security.action.GetPropertyAction;
  6.  
  7. public final class CompositeFont extends Font2D {
  8.    private boolean[] deferredInitialisation;
  9.    String[] componentFileNames;
  10.    String[] componentNames;
  11.    private PhysicalFont[] components;
  12.    int numSlots;
  13.    int numMetricsSlots;
  14.    int[] exclusionRanges;
  15.    int[] maxIndices;
  16.    int numGlyphs = 0;
  17.    int localeSlot = -1;
  18.    boolean isStdComposite = true;
  19.  
  20.    public CompositeFont(String var1, String[] var2, String[] var3, int var4, int[] var5, int[] var6, boolean var7) {
  21.       this.handle = new Font2DHandle(this);
  22.       this.fullName = var1;
  23.       this.componentFileNames = var2;
  24.       this.componentNames = var3;
  25.       if (var3 == null) {
  26.          this.numSlots = this.componentFileNames.length;
  27.       } else {
  28.          this.numSlots = this.componentNames.length;
  29.       }
  30.  
  31.       this.numMetricsSlots = var4;
  32.       this.exclusionRanges = var5;
  33.       this.maxIndices = var6;
  34.       if (FontManager.eudcFont != null) {
  35.          ++this.numSlots;
  36.          if (this.componentNames != null) {
  37.             this.componentNames = new String[this.numSlots];
  38.             System.arraycopy(var3, 0, this.componentNames, 0, this.numSlots - 1);
  39.             this.componentNames[this.numSlots - 1] = FontManager.eudcFont.getFontName((Locale)null);
  40.          }
  41.  
  42.          if (this.componentFileNames != null) {
  43.             this.componentFileNames = new String[this.numSlots];
  44.             System.arraycopy(var2, 0, this.componentFileNames, 0, this.numSlots - 1);
  45.          }
  46.  
  47.          this.components = new PhysicalFont[this.numSlots];
  48.          this.components[this.numSlots - 1] = FontManager.eudcFont;
  49.          this.deferredInitialisation = new boolean[this.numSlots];
  50.          if (var7) {
  51.             for(int var8 = 0; var8 < this.numSlots - 1; ++var8) {
  52.                this.deferredInitialisation[var8] = true;
  53.             }
  54.          }
  55.       } else {
  56.          this.components = new PhysicalFont[this.numSlots];
  57.          this.deferredInitialisation = new boolean[this.numSlots];
  58.          if (var7) {
  59.             for(int var10 = 0; var10 < this.numSlots; ++var10) {
  60.                this.deferredInitialisation[var10] = true;
  61.             }
  62.          }
  63.       }
  64.  
  65.       this.fontRank = 2;
  66.       int var11 = this.fullName.indexOf(46);
  67.       if (var11 > 0) {
  68.          this.familyName = this.fullName.substring(0, var11);
  69.          if (var11 + 1 < this.fullName.length()) {
  70.             String var9 = this.fullName.substring(var11 + 1);
  71.             if ("plain".equals(var9)) {
  72.                this.style = 0;
  73.             } else if ("bold".equals(var9)) {
  74.                this.style = 1;
  75.             } else if ("italic".equals(var9)) {
  76.                this.style = 2;
  77.             } else if ("bolditalic".equals(var9)) {
  78.                this.style = 3;
  79.             }
  80.          }
  81.       } else {
  82.          this.familyName = this.fullName;
  83.       }
  84.  
  85.    }
  86.  
  87.    CompositeFont(PhysicalFont var1, CompositeFont var2) {
  88.       this.isStdComposite = false;
  89.       this.handle = new Font2DHandle(this);
  90.       this.fullName = var1.fullName;
  91.       this.familyName = var1.familyName;
  92.       this.style = var1.style;
  93.       this.numMetricsSlots = 1;
  94.       this.numSlots = var2.numSlots + 1;
  95.       synchronized(FontManager.class) {
  96.          this.components = new PhysicalFont[this.numSlots];
  97.          this.components[0] = var1;
  98.          System.arraycopy(var2.components, 0, this.components, 1, var2.numSlots);
  99.          if (var2.componentNames != null) {
  100.             this.componentNames = new String[this.numSlots];
  101.             this.componentNames[0] = var1.fullName;
  102.             System.arraycopy(var2.componentNames, 0, this.componentNames, 1, var2.numSlots);
  103.          }
  104.  
  105.          if (var2.componentFileNames != null) {
  106.             this.componentFileNames = new String[this.numSlots];
  107.             this.componentFileNames[0] = null;
  108.             System.arraycopy(var2.componentFileNames, 0, this.componentFileNames, 1, var2.numSlots);
  109.          }
  110.  
  111.          this.deferredInitialisation = new boolean[this.numSlots];
  112.          this.deferredInitialisation[0] = false;
  113.          System.arraycopy(var2.deferredInitialisation, 0, this.deferredInitialisation, 1, var2.numSlots);
  114.       }
  115.    }
  116.  
  117.    private void doDeferredInitialisation(int var1) {
  118.       if (this.deferredInitialisation[var1]) {
  119.          synchronized(FontManager.class) {
  120.             if (this.componentNames == null) {
  121.                this.componentNames = new String[this.numSlots];
  122.             }
  123.  
  124.             if (this.components[var1] == null) {
  125.                if (this.componentFileNames != null && this.componentFileNames[var1] != null) {
  126.                   this.components[var1] = FontManager.initialiseDeferredFont(this.componentFileNames[var1]);
  127.                }
  128.  
  129.                if (this.components[var1] == null) {
  130.                   this.components[var1] = FontManager.getDefaultPhysicalFont();
  131.                }
  132.  
  133.                String var3 = this.components[var1].getFontName((Locale)null);
  134.                if (this.componentNames[var1] == null) {
  135.                   this.componentNames[var1] = var3;
  136.                } else if (!this.componentNames[var1].equalsIgnoreCase(var3)) {
  137.                   this.components[var1] = (PhysicalFont)FontManager.findFont2D(this.componentNames[var1], this.style, 1);
  138.                }
  139.             }
  140.  
  141.             this.deferredInitialisation[var1] = false;
  142.          }
  143.       }
  144.    }
  145.  
  146.    void replaceComponentFont(PhysicalFont var1, PhysicalFont var2) {
  147.       if (this.components != null) {
  148.          for(int var3 = 0; var3 < this.numSlots; ++var3) {
  149.             if (this.components[var3] == var1) {
  150.                this.components[var3] = var2;
  151.                if (this.componentNames != null) {
  152.                   this.componentNames[var3] = var2.getFontName((Locale)null);
  153.                }
  154.             }
  155.          }
  156.  
  157.       }
  158.    }
  159.  
  160.    public boolean isExcludedChar(int var1, int var2) {
  161.       if (this.exclusionRanges != null && this.maxIndices != null && var1 < this.numMetricsSlots) {
  162.          int var3 = 0;
  163.          int var4 = this.maxIndices[var1];
  164.          if (var1 > 0) {
  165.             var3 = this.maxIndices[var1 - 1];
  166.          }
  167.  
  168.          for(int var5 = var3; var4 > var5; var5 += 2) {
  169.             if (var2 >= this.exclusionRanges[var5] && var2 <= this.exclusionRanges[var5 + 1]) {
  170.                return true;
  171.             }
  172.          }
  173.  
  174.          return false;
  175.       } else {
  176.          return false;
  177.       }
  178.    }
  179.  
  180.    public void getStyleMetrics(float var1, float[] var2, int var3) {
  181.       PhysicalFont var4 = this.getSlotFont(0);
  182.       if (var4 == null) {
  183.          super.getStyleMetrics(var1, var2, var3);
  184.       } else {
  185.          var4.getStyleMetrics(var1, var2, var3);
  186.       }
  187.  
  188.    }
  189.  
  190.    public int getNumSlots() {
  191.       return this.numSlots;
  192.    }
  193.  
  194.    public PhysicalFont getSlotFont(int var1) {
  195.       if (this.deferredInitialisation[var1]) {
  196.          this.doDeferredInitialisation(var1);
  197.       }
  198.  
  199.       try {
  200.          PhysicalFont var2 = this.components[var1];
  201.          if (var2 == null) {
  202.             try {
  203.                var2 = (PhysicalFont)FontManager.findFont2D(this.componentNames[var1], this.style, 1);
  204.                this.components[var1] = var2;
  205.             } catch (ClassCastException var4) {
  206.                var2 = FontManager.getDefaultPhysicalFont();
  207.             }
  208.          }
  209.  
  210.          return var2;
  211.       } catch (Exception var5) {
  212.          return FontManager.getDefaultPhysicalFont();
  213.       }
  214.    }
  215.  
  216.    FontStrike createStrike(FontStrikeDesc var1) {
  217.       return new CompositeStrike(this, var1);
  218.    }
  219.  
  220.    public boolean isStdComposite() {
  221.       return this.isStdComposite;
  222.    }
  223.  
  224.    protected int getValidatedGlyphCode(int var1) {
  225.       int var2 = var1 >>> 24;
  226.       if (var2 >= this.numSlots) {
  227.          return this.getMapper().getMissingGlyphCode();
  228.       } else {
  229.          int var3 = var1 & 16777215;
  230.          PhysicalFont var4 = this.getSlotFont(var2);
  231.          return var4.getValidatedGlyphCode(var3) == var4.getMissingGlyphCode() ? this.getMapper().getMissingGlyphCode() : var1;
  232.       }
  233.    }
  234.  
  235.    public CharToGlyphMapper getMapper() {
  236.       if (this.mapper == null) {
  237.          this.mapper = new CompositeGlyphMapper(this);
  238.       }
  239.  
  240.       return this.mapper;
  241.    }
  242.  
  243.    public boolean hasSupplementaryChars() {
  244.       for(int var1 = 0; var1 < this.numSlots; ++var1) {
  245.          if (this.getSlotFont(var1).hasSupplementaryChars()) {
  246.             return true;
  247.          }
  248.       }
  249.  
  250.       return false;
  251.    }
  252.  
  253.    public int getNumGlyphs() {
  254.       if (this.numGlyphs == 0) {
  255.          this.numGlyphs = this.getMapper().getNumGlyphs();
  256.       }
  257.  
  258.       return this.numGlyphs;
  259.    }
  260.  
  261.    public int getMissingGlyphCode() {
  262.       return this.getMapper().getMissingGlyphCode();
  263.    }
  264.  
  265.    public boolean canDisplay(char var1) {
  266.       return this.getMapper().canDisplay(var1);
  267.    }
  268.  
  269.    public boolean useAAForPtSize(int var1) {
  270.       if (this.localeSlot == -1) {
  271.          int var2 = this.numMetricsSlots;
  272.          if (var2 == 1 && !this.isStdComposite()) {
  273.             var2 = this.numSlots;
  274.          }
  275.  
  276.          for(int var3 = 0; var3 < var2; ++var3) {
  277.             if (this.getSlotFont(var3).supportsEncoding((String)null)) {
  278.                this.localeSlot = var3;
  279.                break;
  280.             }
  281.          }
  282.  
  283.          if (this.localeSlot == -1) {
  284.             this.localeSlot = 0;
  285.          }
  286.       }
  287.  
  288.       return this.getSlotFont(this.localeSlot).useAAForPtSize(var1);
  289.    }
  290.  
  291.    public String toString() {
  292.       String var1 = (String)AccessController.doPrivileged(new GetPropertyAction("line.separator"));
  293.       String var2 = "";
  294.  
  295.       for(int var3 = 0; var3 < this.numSlots; ++var3) {
  296.          var2 = var2 + "    Slot[" + var3 + "]=" + this.getSlotFont(var3) + var1;
  297.       }
  298.  
  299.       return "** Composite Font: Family=" + this.familyName + " Name=" + this.fullName + " style=" + this.style + var1 + var2;
  300.    }
  301. }
  302.